<?php
global $Config;
require_once($Config->WebCMSRoot.'Data/_baseDB.php');

define('MYSQL_HOST', 'localhost');
define('MYSQL_USER', 'familie_boden');
define('MYSQL_PASSWORD', 'm1llek3');
define('MYSQL_DATABASE', 'familieboden');

Class db extends BaseDB
{
  var $link;
  
	function db()
	{
		$this->link = mysql_pconnect(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD) or die('ERROR [Connect]: '.mysql_error());
		mysql_select_db(MYSQL_DATABASE, $this->link) or die('ERROR [DB]: '.mysql_error());
	}  
	
	function Select($sql)
	{
		$result = mysql_query($sql, $this->link) or die('ERROR [Select]: '.$sql.' - '.mysql_error());

		$rows = array();
		while($row =  mysql_fetch_assoc($result))
		{
			$rows[] = $row;
		}

		return ($rows);
	}
  
	function Execute($sql, $isInsert=false)
	{
		$result = mysql_query($sql, $this->link) or die('ERROR [Execute]: '.mysql_error());

		if ($isInsert)
		{
			return(mysql_insert_id());
		}
	}
	
	function EscapeString($string)
	{
		return mysql_real_escape_string($string);
	}
  
	function DBTimeStampToServerTimeStamp($timestamp)
	{
		$year   = substr($timestamp,  0, 4);
		$month  = substr($timestamp,  4, 2);
		$day    = substr($timestamp,  6, 2);
		$hour   = substr($timestamp,  8, 2);
		$minute = substr($timestamp, 10, 2);
		$second = substr($timestamp, 12, 2);

		return mktime($hour, $minute, $second, $month, $day, $year);
	}

	function ServerTimeStamptoDBTimeStamp($timestamp)
	{
		return date("YmdHis");
	}
}
?>